package com.cn.dim.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cn.dim.dao.InfoDao;
import com.cn.dim.pojo.Dep;
import com.cn.dim.pojo.Info;
import com.cn.dim.service.InfoService;
import com.github.pagehelper.PageHelper;
@Service("infoService")
public class InfoServiceImpl implements InfoService{
	@Resource
	InfoDao infoDao;

	@Override
	public List<Map<String, Object>> queryInfo(Map<String, Object> m) {
		// TODO Auto-generated method stub
		PageHelper.startPage(Integer.valueOf(m.get("pageIndex").toString()),Integer.valueOf(m.get("pageSize").toString()),true);
		return infoDao.queryInfo(m);
	}
	@Override
	public List<Map<String, Object>> queryInfolist(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return infoDao.queryInfolist(m);
	}

	@Override
	public List<Map<String, Object>> queryUser(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return infoDao.queryUser(m);
	}

	@Override
	public int insertInfo(Info i, List<Map<String, Object>> i_us) {
		// TODO Auto-generated method stub
		infoDao.insertInfo(i);
		infoDao.insertInfo_User(i_us);
		
		this.sentWXMessageTemplate(i);//这里需要依据具体情况修改
		return  this.sentWXMessageNormal(i);
	}

	@Override
	public List<Map<String, Object>> queryRole(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return infoDao.queryRole(m);
	}

	@Override
	public List<Dep> queryDep(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return infoDao.queryDep(m);
	}

	@Override
	public List<Map<String, Object>> queryUserByroleid(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return infoDao.queryUserByroleid(m);
	}

	@Override
	public List<Map<String, Object>> queryUserBydepid(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return infoDao.queryUserBydepid(m);
	}

	@Override
	public int updateInfo(Info i, Map<String,Object> m, List<Map<String, Object>> i_us) {
		// TODO Auto-generated method stub
		infoDao.updateInfo(i);
		infoDao.delInfo_User(m);
		return infoDao.insertInfo_User(i_us);
	}

	@Override
	public int delInfo(Map<String, Object> m) {
		// TODO Auto-generated method stub
		infoDao.delInfo(m);
		return infoDao.delInfo_User(m);
	}

	@Override
	public Info queryInfoById(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return infoDao.queryInfoById(m);
	}

	@Override
	public int setInfo_UserIsRead(List<Map<String,Object>> i_us) {
		// TODO Auto-generated method stub
		return infoDao.setInfo_UserIsRead(i_us);
	}

	@Override
	public int sentWXMessageNormal(Info i) {
		// 这里写调用微信公众号普通消息推送的代码
		return 1;
	}

	@Override
	public int sentWXMessageTemplate(Info i) {
		// 这里写调用微信公众号模版消息推送的代码
		return 0;
	}

}
